﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using NativeExcel;
using System.IO;

namespace 产品编码生成工具_Excel
{
    public partial class frmMain : Form
    {
        string[] StandardE24 = { "10", "11", "12", "13", "15", "16", "18", "20", "22", "24", "27", "30", "33", "36", "39", "43", "47", "51", "56", "62", "68", "75", "82", "91" };
        //string[] StandardE24 ={ "10",  "12", "15", "18", "22", "27", "33", "39", "47", "56", "68", "82"};

        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            cmbType.SelectedIndex = 0;
        }

        private void btnBrowse_Source_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "*.xls|*.xls";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                txtFileName_Source.Text = ofd.FileName;
                FileInfo fi=new FileInfo (ofd.FileName );
                txtFileName_Target.Text = fi.FullName.Substring(0, fi.FullName.Length - fi.Extension.Length) + "导出.xls";
                GetExcelTableNames(txtFileName_Source.Text);
                if (cmbWorkSheetNames.Items.Count > 0)
                {
                    cmbWorkSheetNames.SelectedIndex = 0;
                }
            }
        }

        private void btnBrowse_Target_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "*.xls|*.xls";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                txtFileName_Target.Text = sfd.FileName;
            }
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            if (dgv1.Rows.Count == 0)
            {
                MessageBox.Show("没有可转换的数据！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtFileName_Target.Text.Equals(string.Empty))
            {
                MessageBox.Show("请先选择要保存的文件！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DataTable dt = new DataTable();
            DataRow dr;
            switch (cmbType.SelectedIndex)
            {
                case 0:
                    #region 常规原始
                    dt.Columns.Add("原材料物料编码");
                    dt.Columns.Add("原材料名称");
                    dt.Columns.Add("编码");
                    dt.Columns.Add("尺寸");
                    dt.Columns.Add("执行标准");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("生产厂家");
                    dt.Columns.Add("特殊要求");
                    dt.Columns.Add("文件名");
                    dt.Columns.Add("计量单位");
                    dt.Columns.Add("修改后型号");
                    dt.Columns.Add("采用标准");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) <= 0)
                                {

                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["原材料物料编码"] = string.Empty ;
                                                    dr["原材料名称"] = "瓷介电容器";
                                                    dr["尺寸"] = dgv1.Rows[i].Cells["尺寸"].Value;
                                                    dr["执行标准"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["生产厂家"] = "715-6厂";
                                                    dr["特殊要求"] = string.Empty;
                                                    dr["文件名"] = string.Empty;
                                                    dr["计量单位"] = "个";
                                                    dr["修改后型号"] = string.Empty;
                                                    dr["采用标准"] = string.Empty;

                                                    //dt.Columns.Add("型号规格");
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["编码"] ="("+ GetString(dgv1.Rows[i].Cells["质量等级"].Value) + ")" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["编码"]).Contains("--"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["编码"]).EndsWith("-"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["编码"] = "(" + GetString(dgv1.Rows[i].Cells["质量等级"].Value) + ")" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["编码"]).Contains("--"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["编码"]).EndsWith("-"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                        }
                                                    }
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr = dt.NewRow();
                                                    dr["原材料物料编码"] = string.Empty;
                                                    dr["原材料名称"] = "瓷介电容器";
                                                    dr["尺寸"] = dgv1.Rows[i].Cells["尺寸"].Value;
                                                    dr["执行标准"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["生产厂家"] = "715-6厂";
                                                    dr["特殊要求"] = string.Empty;
                                                    dr["文件名"] = string.Empty;
                                                    dr["计量单位"] = "个";
                                                    dr["修改后型号"] = string.Empty;
                                                    dr["采用标准"] = string.Empty;
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["编码"] = "(" + GetString(dgv1.Rows[i].Cells["质量等级"].Value) + ")" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["编码"]).Contains("--"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["编码"]).EndsWith("-"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["编码"] = "(" + GetString(dgv1.Rows[i].Cells["质量等级"].Value) + ")" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["编码"]).Contains("--"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["编码"]).EndsWith("-"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                        }
                                                    }
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                    if (LevelIndex >= 0)
                                    {
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 1:
                    #region 板式阵列滤波电容器
                    dt.Columns.Add("序号");
                    dt.Columns.Add("物料编码");
                    dt.Columns.Add("物料全称");
                    dt.Columns.Add("名称");
                    dt.Columns.Add("设计类型");
                    dt.Columns.Add("简称");
                    dt.Columns.Add("编码");
                    dt.Columns.Add("型号");
                    dt.Columns.Add("执行标准");
                    dt.Columns.Add("代号");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("厂家");
                    dt.Columns.Add("备注");
                    dt.Columns.Add("计量单位");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            dr = dt.NewRow();
                            dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                            dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                            dr["型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value);
                            dr["编码"] = GetString(dr["型号"]) + "-" +
                                GetString(dgv1.Rows[i].Cells["滤波电路形式"].Value) + "-" +
                                GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                               GetString(dgv1.Rows[i].Cells["容量"].Value) +
                               GetString(dgv1.Rows[i].Cells["精度"].Value) + "-" +
                                GetString(dgv1.Rows[i].Cells["配套电连接器标准代号"].Value) + "-" +
                                GetString(dgv1.Rows[i].Cells["配套电连接器绝缘安装板代号"].Value);
                            while (GetString(dr["编码"]).Contains("--"))
                            {
                                dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                            }
                            dr["序号"] = dt.Rows.Count + 1;
                            dr["物料全称"] = "电容器";
                            dr["名称"] = "电容器" + GetString(dr["编码"]);
                            dr["设计类型"] = "元器件";
                            dr["简称"] = "电容器";
                            dr["代号"] = dr["执行标准"];
                            dr["厂家"] = "成都宏明电子科大新材料有限公司";
                            dr["计量单位"] = "只";
                            dr["备注"] = "宏科电子";
                            dt.Rows.Add(dr);
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 2:
                    #region 薄膜电阻
                    //dt.Columns.Add("执行标准");
                    //dt.Columns.Add("质量等级");
                    //dt.Columns.Add("型号");
                    //dt.Columns.Add("尺寸");
                    //dt.Columns.Add("阻值");
                    //dt.Columns.Add("精度");
                    //dt.Columns.Add("电极材料代码");
                    //dt.Columns.Add("引出端形式");
                    //dt.Columns.Add("备注");
                    //dt.Columns.Add("编码");
                    //for (int i = 0; i < dgv1.Rows.Count; i++)
                    //{
                    //    try
                    //    {
                    //        string[] strDjcl = GetString(dgv1.Rows[i].Cells["电极材料代码"].Value).Split(new char[] { ';' });
                    //        for (int k = 0; k < strDjcl.Length; k++)
                    //        {
                    //            if (strDjcl[k].Trim().Equals(string.Empty))
                    //            {
                    //                continue;
                    //            }
                    //            dr = dt.NewRow();
                    //            dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                    //            dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                    //            dr["型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value);
                    //            dr["尺寸"] = GetString(dgv1.Rows[i].Cells["尺寸"].Value);
                    //            dr["阻值"] = GetString(dgv1.Rows[i].Cells["阻值"].Value);
                    //            dr["精度"] = GetString(dgv1.Rows[i].Cells["精度"].Value);
                    //            dr["电极材料代码"] = strDjcl[k];
                    //            dr["引出端形式"] = GetString(dgv1.Rows[i].Cells["引出端形式"].Value);
                    //            dr["编码"] = GetString(dr["型号"]) + "-" +
                    //                GetString(dr["尺寸"]) + "-" +
                    //                GetString(dr["阻值"]) +
                    //                GetString(dr["精度"])+ "-" +
                    //                GetString(dr["电极材料代码"])+ "-" +
                    //                GetString(dr["引出端形式"]);
                    //            while (GetString(dr["编码"]).Contains("--"))
                    //            {
                    //                dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                    //            }
                    //            dr["备注"] = GetString(dgv1.Rows[i].Cells["备注"].Value);
                    //            dt.Rows.Add(dr);
                    //        }
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    //        txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                    //        continue;
                    //    }
                    //}
                    #endregion
                    break;
                case 3:
                    #region HKI-9510
                    //dt.Columns.Add("执行标准");
                    //dt.Columns.Add("质量等级");
                    //dt.Columns.Add("型号");
                    //dt.Columns.Add("尺寸");
                    //dt.Columns.Add("备注");
                    //dt.Columns.Add("编码");
                    //for (int i = 0; i < dgv1.Rows.Count; i++)
                    //{
                    //    try
                    //    {
                    //        dr = dt.NewRow();
                    //        dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                    //        dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                    //        dr["型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value);
                    //        dr["尺寸"] = GetString(dgv1.Rows[i].Cells["尺寸"].Value);
                    //        dr["编码"] = GetString(dr["型号"]) + "-" +
                    //            GetString(dr["尺寸"]);
                    //        while (GetString(dr["编码"]).Contains("--"))
                    //        {
                    //            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                    //        }
                    //        dr["备注"] = GetString(dgv1.Rows[i].Cells["备注"].Value);
                    //        dt.Rows.Add(dr);
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    //        txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                    //        continue;
                    //    }
                    //}
                    #endregion
                    break;
                case 4:
                    #region HKI除9510外
                    //dt.Columns.Add("执行标准");
                    //dt.Columns.Add("质量等级");
                    //dt.Columns.Add("型号");
                    //dt.Columns.Add("尺寸");
                    //dt.Columns.Add("容量");
                    //dt.Columns.Add("精度");
                    //dt.Columns.Add("备注");
                    //dt.Columns.Add("编码");
                    //for (int i = 0; i < dgv1.Rows.Count; i++)
                    //{
                    //    try
                    //    {
                    //        if (GetString(dgv1.Rows[i].Cells["容量起"].Value).Equals(string.Empty) ||
                    //            GetString(dgv1.Rows[i].Cells["容量止"].Value).Equals(string.Empty))
                    //        {
                    //            dr = dt.NewRow();
                    //            dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                    //            dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                    //            dr["型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value);
                    //            dr["尺寸"] = GetString(dgv1.Rows[i].Cells["尺寸"].Value);
                    //            dr["容量"] = GetString(dgv1.Rows[i].Cells["容量起"].Value)+"-"+
                    //                                GetString(dgv1.Rows[i].Cells["容量止"].Value);
                    //            dr["容量"] = GetString(dr["容量"]).Replace ("-",string.Empty );
                    //            dr["精度"] = GetString(dgv1.Rows[i].Cells["精度"].Value);
                    //            dr["编码"] = GetString(dr["型号"]) + "-" +
                    //                GetString(dr["尺寸"]) + "-" +
                    //                GetString(dr["容量"]) +
                    //                GetString(dr["精度"]);
                    //            while (GetString(dr["编码"]).Contains("--"))
                    //            {
                    //                dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                    //            }
                    //            if (GetString(dr["编码"]).EndsWith("-"))
                    //            {
                    //                dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                    //            }
                    //            dr["备注"] = GetString(dgv1.Rows[i].Cells["备注"].Value);
                    //            dt.Rows.Add(dr);
                    //            continue ;
                    //        }
                    //        string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                    //        string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                    //        string strCurrentCapacity = strCapacityMin;
                    //        int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                    //        int PowerLevel = GetPowerLevel(strCurrentCapacity);
                    //        while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) == -1)
                    //        {
                    //            if (LevelIndex < 0)
                    //            {
                    //                LevelIndex++;
                    //            }
                    //            if (PowerLevel < 0)
                    //            {
                    //                strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                    //            }
                    //            else
                    //            {
                    //                strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                    //            }
                    //            dr = dt.NewRow();
                    //            dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                    //            dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                    //            dr["型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value);
                    //            dr["尺寸"] = GetString(dgv1.Rows[i].Cells["尺寸"].Value);
                    //            dr["容量"] = strCurrentCapacity;
                    //            dr["精度"] = GetString(dgv1.Rows[i].Cells["精度"].Value);
                    //            dr["编码"] = GetString(dr["型号"]) + "-" +
                    //                GetString(dr["尺寸"]) + "-" +
                    //                GetString(dr["容量"]) +
                    //                GetString(dr["精度"]);
                    //            while (GetString(dr["编码"]).Contains("--"))
                    //            {
                    //                dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                    //            }
                    //            if (GetString(dr["编码"]).EndsWith("-"))
                    //            {
                    //                dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                    //            }
                    //            dr["备注"] = GetString(dgv1.Rows[i].Cells["备注"].Value);
                    //            dt.Rows.Add(dr);
                    //            LevelIndex++;
                    //            if (LevelIndex == StandardE24.Length)
                    //            {
                    //                LevelIndex = 0;
                    //                PowerLevel++;
                    //            }
                    //        }
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    //        txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                    //        continue;
                    //    }
                    //}
                    #endregion
                    break;
                case 5:
                    #region LC
                    //dt.Columns.Add("执行标准");
                    //dt.Columns.Add("质量等级");
                    //dt.Columns.Add("型号");
                    //dt.Columns.Add("电压");
                    //dt.Columns.Add("容量");
                    //dt.Columns.Add("精度");
                    //dt.Columns.Add("备注");
                    //dt.Columns.Add("编码");
                    //for (int i = 0; i < dgv1.Rows.Count; i++)
                    //{
                    //    try
                    //    {
                    //        dr = dt.NewRow();
                    //        dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                    //        dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                    //        dr["型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value);
                    //        dr["电压"] = GetString(dgv1.Rows[i].Cells["电压"].Value);
                    //        dr["容量"] = GetString(dgv1.Rows[i].Cells["容量"].Value);
                    //        dr["精度"] = GetString(dgv1.Rows[i].Cells["精度"].Value);
                    //        dr["编码"] = GetString(dr["型号"]) + "-" +
                    //            GetString(dr["电压"]) + "-" +
                    //            GetString(dr["容量"]) +
                    //            GetString(dr["精度"]);
                    //        while (GetString(dr["编码"]).Contains("--"))
                    //        {
                    //            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                    //        }
                    //        dr["备注"] = GetString(dgv1.Rows[i].Cells["备注"].Value);
                    //        dt.Rows.Add(dr);
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    //        txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                    //        continue;
                    //    }
                    //}
                    #endregion
                    break;
                case 6:
                    #region 单层片式电容器
                    dt.Columns.Add("编码");
                    dt.Columns.Add("尺寸");
                    dt.Columns.Add("容量");
                    dt.Columns.Add("精度");
                    dt.Columns.Add("电压");
                    dt.Columns.Add("执行标准");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("备注");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                int iCount = 0;
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) == -1)
                                {
                                    if (iCount > 0)
                                    {
                                        if (LevelIndex < 0)
                                        {
                                            LevelIndex++;
                                        }
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strMaterials= GetString(dgv1.Rows[i].Cells["电极材料代码"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strMaterials.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["编码"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                        GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                        strSpecials[k] + "-" +
                                                        GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                        strCurrentCapacity +
                                                        strAccuracies[j] + "-" +
                                                        GetString(dgv1.Rows[i].Cells["电极外形代码"].Value) + "-" +
                                                        strMaterials[m] + "-" +
                                                        GetString(dgv1.Rows[i].Cells["电容数量"].Value);
                                                    while (GetString(dr["编码"]).Contains("--"))
                                                    {
                                                        dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                    }
                                                    if (GetString(dr["编码"]).EndsWith("-"))
                                                    {
                                                        dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                    }
                                                    dr["尺寸"]= GetString(dgv1.Rows[i].Cells["尺寸"].Value);
                                                    dr["容量"] = strCurrentCapacity;
                                                    dr["精度"] = strAccuracies[j];
                                                    dr["电压"] = GetString(dgv1.Rows[i].Cells["电压"].Value);
                                                    dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                                                    dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                                                    dr["备注"] = GetString(dr["备注"]);
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strMaterials = GetString(dgv1.Rows[i].Cells["电极材料代码"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strMaterials.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["编码"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                        GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                        strSpecials[k] + "-" +
                                                        GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                        strCurrentCapacity +
                                                        strAccuracies[j] + "-" +
                                                        GetString(dgv1.Rows[i].Cells["电极外形代码"].Value) + "-" +
                                                        strMaterials[m] + "-" +
                                                        GetString(dgv1.Rows[i].Cells["电容数量"].Value);
                                                    while (GetString(dr["编码"]).Contains("--"))
                                                    {
                                                        dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                    }
                                                    if (GetString(dr["编码"]).EndsWith("-"))
                                                    {
                                                        dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                    }
                                                    dr["尺寸"] = GetString(dgv1.Rows[i].Cells["尺寸"].Value);
                                                    dr["容量"] = strCurrentCapacity;
                                                    dr["精度"] = strAccuracies[j];
                                                    dr["电压"] = GetString(dgv1.Rows[i].Cells["电压"].Value);
                                                    dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                                                    dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                                                    dr["备注"] = GetString(dr["备注"]);
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    iCount++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text += "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 7:
                    #region 多芯组
                    dt.Columns.Add("编码");
                    dt.Columns.Add("尺寸");
                    dt.Columns.Add("容量");
                    dt.Columns.Add("精度");
                    dt.Columns.Add("电压");
                    dt.Columns.Add("执行标准");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("备注");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                if (strCapacityMin.Equals(string.Empty) ||
                                    strCapacityMax.Equals(string.Empty))
                                {
                                    string strCapacity = strCapacityMin + "-" + strCapacityMax;
                                    strCapacity = strCapacity.Replace("-", string.Empty);
                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                        for (int m = 0; m < strTerminals.Length; m++)
                                        {
                                            if (strTerminals[m].Equals(string.Empty))
                                            {
                                                continue;
                                            }
                                            string[] strFzlx = GetString(dgv1.Rows[i].Cells["堆叠与封装类型"].Value).Split(new char[] { ';' });
                                            for (int l = 0; l < strFzlx.Length; l++)
                                            {
                                                if (strFzlx[l].Equals(string.Empty))
                                                {
                                                    continue;
                                                }
                                                dr = dt.NewRow();
                                                dr["编码"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                     strFzlx[l] + "-" +
                                                    GetString(dgv1.Rows[i].Cells["尺寸代号、堆叠只数"].Value) + "-" +
                                                    strTerminals[m] + "-" +
                                                    GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                    strSpecials[k] + "-" +
                                                    strCapacity +
                                                    strAccuracies[j];
                                                while (GetString(dr["编码"]).Contains("--"))
                                                {
                                                    dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                }
                                                if (GetString(dr["编码"]).EndsWith("-"))
                                                {
                                                    dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                }
                                                dr["尺寸"] = GetString(dgv1.Rows[i].Cells["尺寸代号、堆叠只数"].Value);
                                                dr["容量"] = strCapacity;
                                                dr["精度"] = strAccuracies[j];
                                                dr["电压"] = GetString(dgv1.Rows[i].Cells["电压"].Value);
                                                dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                                                dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                                                dr["备注"] = GetString(dgv1.Rows[i].Cells["备注"].Value);
                                                dt.Rows.Add(dr);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    string strCurrentCapacity = strCapacityMin;
                                    int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                    int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                    while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) == -1)
                                    {
                                        if (LevelIndex < 0)
                                        {
                                            LevelIndex++;
                                        }
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                        string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                        for (int j = 0; j < strAccuracies.Length; j++)
                                        {
                                            if (strAccuracies[j].Trim().Equals(string.Empty))
                                            {
                                                continue;
                                            }
                                            string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                            for (int m = 0; m < strTerminals.Length; m++)
                                            {
                                                if (strTerminals[m].Equals(string.Empty))
                                                {
                                                    continue;
                                                }
                                                string[] strFzlx = GetString(dgv1.Rows[i].Cells["堆叠与封装类型"].Value).Split(new char[] { ';' });
                                                for (int l = 0; l < strFzlx.Length; l++)
                                                {
                                                    if (strFzlx[l].Equals(string.Empty))
                                                    {
                                                        continue;
                                                    }
                                                    dr = dt.NewRow();
                                                    dr["编码"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                    strFzlx[l] + "-" +
                                                   GetString(dgv1.Rows[i].Cells["尺寸代号、堆叠只数"].Value) + "-" +
                                                   strTerminals[m] + "-" +
                                                   GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                   strSpecials[k] + "-" +
                                                   strCurrentCapacity +
                                                   strAccuracies[j];
                                                    while (GetString(dr["编码"]).Contains("--"))
                                                    {
                                                        dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                    }
                                                    if (GetString(dr["编码"]).EndsWith("-"))
                                                    {
                                                        dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                    }
                                                    dr["尺寸"] = GetString(dgv1.Rows[i].Cells["尺寸代号、堆叠只数"].Value);
                                                    dr["容量"] = strCurrentCapacity ;
                                                    dr["精度"] = strAccuracies[j];
                                                    dr["电压"] = GetString(dgv1.Rows[i].Cells["电压"].Value);
                                                    dr["执行标准"] = GetString(dgv1.Rows[i].Cells["执行标准"].Value);
                                                    dr["质量等级"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value);
                                                    dr["备注"] = GetString(dgv1.Rows[i].Cells["备注"].Value);
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                        }
                                        LevelIndex++;
                                        if (LevelIndex == StandardE24.Length)
                                        {
                                            LevelIndex = 0;
                                            PowerLevel++;
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 8:
                    #region 塞斯库特种厂
                    dt.Columns.Add("物资ID");
                    dt.Columns.Add("大类");
                    dt.Columns.Add("小类");
                    dt.Columns.Add("元器件名称");
                    dt.Columns.Add("规格型号");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("工作温度范围");
                    dt.Columns.Add("生产厂家");
                    dt.Columns.Add("国产/进口");
                    dt.Columns.Add("封装形式");
                    dt.Columns.Add("封装尺寸");
                    dt.Columns.Add("规范号");
                    dt.Columns.Add("认证源");
                    dt.Columns.Add("替代型号");
                    dt.Columns.Add("介质类型");
                    dt.Columns.Add("容值");
                    dt.Columns.Add("电压");
                    dt.Columns.Add("精度");
                    dt.Columns.Add("温度特性");
                    dt.Columns.Add("电子手册");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) <= 0)
                                {

                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    //物资ID; 大类; 小类; 元器件名称; 规格型号; 质量等级; 工作温度范围; 生产厂家; 国产 / 进口;
                                                    //封装形式; 封窗尺寸; 规范号; 认证源; 替代型号; 介质类型; 容值; 电压; 精度; 温度特性; 电子手册;
                                                    dr["物资ID"] = string.Empty;
                                                    dr["大类"] ="电容器";
                                                    dr["小类"] ="瓷介电容器";
                                                    dr["元器件名称"] = dgv1.Rows[i].Cells["元器件名称"].Value;
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["工作温度范围"] = dgv1.Rows[i].Cells["工作温度范围"].Value;
                                                    dr["生产厂家"] ="成都宏明电子科大新材料有限公司";
                                                    dr["国产/进口"] ="国产";
                                                    dr["封装形式"] = dgv1.Rows[i].Cells["封装形式"].Value;
                                                    dr["封装尺寸"] = dgv1.Rows[i].Cells["封装尺寸"].Value;
                                                    dr["规范号"] = dgv1.Rows[i].Cells["规范号"].Value;
                                                    dr["认证源"] = dgv1.Rows[i].Cells["认证源"].Value;
                                                    dr["替代型号"] = dgv1.Rows[i].Cells["替代型号"].Value;
                                                    dr["介质类型"] = dgv1.Rows[i].Cells["介质类型"].Value;
                                                    dr["容值"] = CapactiyTranslate(strCurrentCapacity);
                                                    dr["电压"] = dgv1.Rows[i].Cells["电压"].Value;
                                                    dr["精度"] = AccuraciesTranslate(strAccuracies[j]);
                                                    dr["温度特性"] = SpecialTranslate(strSpecials[k]);
                                                    dr["电子手册"] = dgv1.Rows[i].Cells["电子手册"].Value;
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["规格型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["规格型号"]).Contains("--"))
                                                        {
                                                            dr["规格型号"] = GetString(dr["规格型号"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["规格型号"]).EndsWith("-"))
                                                        {
                                                            dr["规格型号"] = GetString(dr["规格型号"]).Substring(0, GetString(dr["规格型号"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["规格型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["规格型号"]).Contains("--"))
                                                        {
                                                            dr["规格型号"] = GetString(dr["规格型号"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["规格型号"]).EndsWith("-"))
                                                        {
                                                            dr["规格型号"] = GetString(dr["规格型号"]).Substring(0, GetString(dr["规格型号"]).Length - 1);
                                                        }
                                                    }
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["物资ID"] = string.Empty;
                                                    dr["大类"] = "电容器";
                                                    dr["小类"] = "瓷介电容器";
                                                    dr["元器件名称"] = dgv1.Rows[i].Cells["元器件名称"].Value;
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["工作温度范围"] = dgv1.Rows[i].Cells["工作温度范围"].Value;
                                                    dr["生产厂家"] = "成都宏明电子科大新材料有限公司";
                                                    dr["国产/进口"] = "国产";
                                                    dr["封装形式"] = dgv1.Rows[i].Cells["封装形式"].Value;
                                                    dr["封装尺寸"] = dgv1.Rows[i].Cells["封装尺寸"].Value;
                                                    dr["规范号"] = dgv1.Rows[i].Cells["规范号"].Value;
                                                    dr["认证源"] = dgv1.Rows[i].Cells["认证源"].Value;
                                                    dr["替代型号"] = dgv1.Rows[i].Cells["替代型号"].Value;
                                                    dr["介质类型"] = dgv1.Rows[i].Cells["介质类型"].Value;
                                                    dr["容值"] = CapactiyTranslate(strCurrentCapacity);
                                                    dr["电压"] = dgv1.Rows[i].Cells["电压"].Value;
                                                    dr["精度"] = AccuraciesTranslate(strAccuracies[j]);
                                                    dr["温度特性"] = SpecialTranslate(strSpecials[k]);
                                                    dr["电子手册"] = dgv1.Rows[i].Cells["电子手册"].Value;
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["规格型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["规格型号"]).Contains("--"))
                                                        {
                                                            dr["规格型号"] = GetString(dr["规格型号"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["规格型号"]).EndsWith("-"))
                                                        {
                                                            dr["规格型号"] = GetString(dr["规格型号"]).Substring(0, GetString(dr["规格型号"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["规格型号"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["规格型号"]).Contains("--"))
                                                        {
                                                            dr["规格型号"] = GetString(dr["规格型号"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["规格型号"]).EndsWith("-"))
                                                        {
                                                            dr["规格型号"] = GetString(dr["规格型号"]).Substring(0, GetString(dr["规格型号"]).Length - 1);
                                                        }
                                                    }
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                    if (LevelIndex >= 0)
                                    {
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 9:
                    #region 970
                    dt.Columns.Add("编码");
                    dt.Columns.Add("型号");
                    dt.Columns.Add("尺寸");
                    dt.Columns.Add("执行标准");
                    dt.Columns.Add("有无订货历史");
                    dt.Columns.Add("分类");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) <= 0)
                                {

                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["型号"] = dgv1.Rows[i].Cells["型号"].Value;
                                                    dr["尺寸"] = dgv1.Rows[i].Cells["尺寸"].Value;
                                                    dr["执行标准"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["有无订货历史"] = "否";
                                                    dr["分类"] = dgv1.Rows[i].Cells["分类"].Value;
                                                    //dt.Columns.Add("型号规格");
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["编码"] =GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["编码"]).Contains("--"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["编码"]).EndsWith("-"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["编码"]).Contains("--"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["编码"]).EndsWith("-"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                        }
                                                    }
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["型号"] = dgv1.Rows[i].Cells["型号"].Value;
                                                    dr["尺寸"] = dgv1.Rows[i].Cells["尺寸"].Value;
                                                    dr["执行标准"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["有无订货历史"] = "否";
                                                    dr["分类"] = dgv1.Rows[i].Cells["分类"].Value;
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["编码"]).Contains("--"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["编码"]).EndsWith("-"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["编码"]).Contains("--"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["编码"]).EndsWith("-"))
                                                        {
                                                            dr["编码"] = GetString(dr["编码"]).Substring(0, GetString(dr["编码"]).Length - 1);
                                                        }
                                                    }
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                    if (LevelIndex >= 0)
                                    {
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 10:
                    #region 贵州航天控制技术有限公司
                    dt.Columns.Add("物料分类");
                    dt.Columns.Add("编码");
                    dt.Columns.Add("全称");
                    dt.Columns.Add("简称");
                    dt.Columns.Add("型号规格");
                    dt.Columns.Add("计量单位");
                    dt.Columns.Add("外形尺寸");
                    dt.Columns.Add("质量保证等级");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("厂家代码");
                    dt.Columns.Add("厂家名称");
                    dt.Columns.Add("牌号");
                    dt.Columns.Add("采用标准");
                    dt.Columns.Add("牌号标准");
                    dt.Columns.Add("默认库房");
                    dt.Columns.Add("名称");
                    dt.Columns.Add("Expr1");
                    dt.Columns.Add("designator");
                    dt.Columns.Add("选用单位");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) <= 0)
                                {

                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["物料分类"] ="电容器";
                                                    dr["编码"] =string.Empty ;
                                                    dr["全称"] =string.Empty ;
                                                    dr["简称"] ="电容器";
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    dr["计量单位"] ="只";
                                                    dr["外形尺寸"] = dgv1.Rows[i].Cells["外形尺寸"].Value;
                                                    dr["质量保证等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["客户等级"].Value; 
                                                    dr["厂家代码"] =string.Empty ;
                                                    dr["厂家名称"] ="成都宏明电子科大新材料有限公司";
                                                    dr["牌号"] =string.Empty ;
                                                    dr["采用标准"] = dgv1.Rows[i].Cells["执行标准"].Value; 
                                                    dr["牌号标准"] =string.Empty ;
                                                    dr["默认库房"] ="元器件";
                                                    dr["名称"] = "电容器"+GetString (dr["型号规格"]);
                                                    dr["Expr1"] = dr["型号规格"];
                                                    dr["designator"] ="C";
                                                    dr["选用单位"] = "405";
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["物料分类"] = "电容器";
                                                    dr["编码"] = string.Empty;
                                                    dr["全称"] = dgv1.Rows[i].Cells["产品名称"].Value;
                                                    dr["简称"] = "电容器";
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    dr["计量单位"] = "只";
                                                    dr["外形尺寸"] = dgv1.Rows[i].Cells["外形尺寸"].Value;
                                                    dr["质量保证等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["客户等级"].Value;
                                                    dr["厂家代码"] = string.Empty;
                                                    dr["厂家名称"] = "成都宏明电子科大新材料有限公司";
                                                    dr["牌号"] = string.Empty;
                                                    dr["采用标准"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["牌号标准"] = string.Empty;
                                                    dr["默认库房"] = "元器件";
                                                    dr["名称"] = "电容器" + GetString(dr["型号规格"]);
                                                    dr["Expr1"] = dr["型号规格"];
                                                    dr["designator"] = "C";
                                                    dr["选用单位"] = "405";
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                    if (LevelIndex >= 0)
                                    {
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 11:
                    #region 广州五所
                    dt.Columns.Add("COMPID");
                    dt.Columns.Add("发布情况");
                    dt.Columns.Add("是否同意在2016年版发布");
                    dt.Columns.Add("不发布的理由");
                    dt.Columns.Add("生产商");
                    dt.Columns.Add("元器件名称");
                    dt.Columns.Add("系列型号");
                    dt.Columns.Add("详细规格");
                    dt.Columns.Add("供货状态");
                    dt.Columns.Add("通用规范编号");
                    dt.Columns.Add("详细规范编号");
                    dt.Columns.Add("附加技术协议");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("封装外形");
                    dt.Columns.Add("替代型号(厂家)");
                    dt.Columns.Add("是否使用进口芯片");
                    dt.Columns.Add("项目来源");
                    dt.Columns.Add("单价");
                    dt.Columns.Add("年供货能力");
                    dt.Columns.Add("生产供货周期");
                    dt.Columns.Add("重量");
                    dt.Columns.Add("耐久性试验");
                    dt.Columns.Add("鉴定类型");
                    dt.Columns.Add("鉴定日期");
                    dt.Columns.Add("组织鉴定机构");
                    dt.Columns.Add("详细规范");
                    dt.Columns.Add("技术资料");
                    dt.Columns.Add("外形尺寸图");
                    dt.Columns.Add("实物照片图");
                    dt.Columns.Add("产品特点及用途");
                    dt.Columns.Add("备注");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) <= 0)
                                {

                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["COMPID"]=dgv1.Rows[i].Cells["COMPID"].Value ;
                                                    dr["发布情况"]=dgv1.Rows[i].Cells["发布情况"].Value;
                                                    dr["是否同意在2016年版发布"]=dgv1.Rows[i].Cells["是否同意在2016年版发布"].Value;
                                                    dr["不发布的理由"]=dgv1.Rows[i].Cells["不发布的理由"].Value;
                                                    dr["生产商"]=dgv1.Rows[i].Cells["生产商"].Value;
                                                    dr["元器件名称"]=dgv1.Rows[i].Cells["元器件名称"].Value;
                                                    dr["系列型号"]=dgv1.Rows[i].Cells["系列型号"].Value;
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["详细规格"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["系列型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["详细规格"]).Contains("--"))
                                                        {
                                                            dr["详细规格"] = GetString(dr["详细规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["详细规格"]).EndsWith("-"))
                                                        {
                                                            dr["详细规格"] = GetString(dr["详细规格"]).Substring(0, GetString(dr["详细规格"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["详细规格"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["系列型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["详细规格"]).Contains("--"))
                                                        {
                                                            dr["详细规格"] = GetString(dr["详细规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["详细规格"]).EndsWith("-"))
                                                        {
                                                            dr["详细规格"] = GetString(dr["详细规格"]).Substring(0, GetString(dr["详细规格"]).Length - 1);
                                                        }
                                                    }
                                                    dr["供货状态"] = dgv1.Rows[i].Cells["供货状态"].Value;
                                                    dr["通用规范编号"] = dgv1.Rows[i].Cells["通用规范编号"].Value;
                                                    dr["详细规范编号"] = dgv1.Rows[i].Cells["详细规范编号"].Value;
                                                    dr["附加技术协议"] = dgv1.Rows[i].Cells["附加技术协议"].Value;
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["封装外形"] = dgv1.Rows[i].Cells["封装外形"].Value;
                                                    dr["替代型号(厂家)"] = dgv1.Rows[i].Cells["替代型号(厂家)"].Value;
                                                    dr["是否使用进口芯片"] = dgv1.Rows[i].Cells["是否使用进口芯片"].Value;
                                                    dr["项目来源"] = dgv1.Rows[i].Cells["项目来源"].Value;
                                                    dr["单价"] = dgv1.Rows[i].Cells["单价"].Value;
                                                    dr["年供货能力"] = dgv1.Rows[i].Cells["年供货能力"].Value;
                                                    dr["生产供货周期"] = dgv1.Rows[i].Cells["生产供货周期"].Value;
                                                    dr["重量"] = dgv1.Rows[i].Cells["重量"].Value;
                                                    dr["耐久性试验"] = dgv1.Rows[i].Cells["耐久性试验"].Value;
                                                    dr["鉴定类型"] = dgv1.Rows[i].Cells["鉴定类型"].Value;
                                                    dr["鉴定日期"] = dgv1.Rows[i].Cells["鉴定日期"].Value;
                                                    dr["组织鉴定机构"] = dgv1.Rows[i].Cells["组织鉴定机构"].Value;
                                                    dr["详细规范"] = dgv1.Rows[i].Cells["详细规范"].Value;
                                                    dr["技术资料"] = dgv1.Rows[i].Cells["技术资料"].Value;
                                                    dr["外形尺寸图"] = dgv1.Rows[i].Cells["外形尺寸图"].Value;
                                                    dr["实物照片图"] = dgv1.Rows[i].Cells["实物照片图"].Value;
                                                    dr["产品特点及用途"] = dgv1.Rows[i].Cells["产品特点及用途"].Value;
                                                    dr["备注"] = dgv1.Rows[i].Cells["备注"].Value;
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    dr["COMPID"] = dgv1.Rows[i].Cells["COMPID"].Value;
                                                    dr["发布情况"] = dgv1.Rows[i].Cells["发布情况"].Value;
                                                    dr["是否同意在2016年版发布"] = dgv1.Rows[i].Cells["是否同意在2016年版发布"].Value;
                                                    dr["不发布的理由"] = dgv1.Rows[i].Cells["不发布的理由"].Value;
                                                    dr["生产商"] = dgv1.Rows[i].Cells["生产商"].Value;
                                                    dr["元器件名称"] = dgv1.Rows[i].Cells["元器件名称"].Value;
                                                    dr["系列型号"] = dgv1.Rows[i].Cells["系列型号"].Value;
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["详细规格"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["系列型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["详细规格"]).Contains("--"))
                                                        {
                                                            dr["详细规格"] = GetString(dr["详细规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["详细规格"]).EndsWith("-"))
                                                        {
                                                            dr["详细规格"] = GetString(dr["详细规格"]).Substring(0, GetString(dr["详细规格"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["详细规格"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["系列型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["详细规格"]).Contains("--"))
                                                        {
                                                            dr["详细规格"] = GetString(dr["详细规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["详细规格"]).EndsWith("-"))
                                                        {
                                                            dr["详细规格"] = GetString(dr["详细规格"]).Substring(0, GetString(dr["详细规格"]).Length - 1);
                                                        }
                                                    }
                                                    dr["供货状态"] = dgv1.Rows[i].Cells["供货状态"].Value;
                                                    dr["通用规范编号"] = dgv1.Rows[i].Cells["通用规范编号"].Value;
                                                    dr["详细规范编号"] = dgv1.Rows[i].Cells["详细规范编号"].Value;
                                                    dr["附加技术协议"] = dgv1.Rows[i].Cells["附加技术协议"].Value;
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["封装外形"] = dgv1.Rows[i].Cells["封装外形"].Value;
                                                    dr["替代型号(厂家)"] = dgv1.Rows[i].Cells["替代型号(厂家)"].Value;
                                                    dr["是否使用进口芯片"] = dgv1.Rows[i].Cells["是否使用进口芯片"].Value;
                                                    dr["项目来源"] = dgv1.Rows[i].Cells["项目来源"].Value;
                                                    dr["单价"] = dgv1.Rows[i].Cells["单价"].Value;
                                                    dr["年供货能力"] = dgv1.Rows[i].Cells["年供货能力"].Value;
                                                    dr["生产供货周期"] = dgv1.Rows[i].Cells["生产供货周期"].Value;
                                                    dr["重量"] = dgv1.Rows[i].Cells["重量"].Value;
                                                    dr["耐久性试验"] = dgv1.Rows[i].Cells["耐久性试验"].Value;
                                                    dr["鉴定类型"] = dgv1.Rows[i].Cells["鉴定类型"].Value;
                                                    dr["鉴定日期"] = dgv1.Rows[i].Cells["鉴定日期"].Value;
                                                    dr["组织鉴定机构"] = dgv1.Rows[i].Cells["组织鉴定机构"].Value;
                                                    dr["详细规范"] = dgv1.Rows[i].Cells["详细规范"].Value;
                                                    dr["技术资料"] = dgv1.Rows[i].Cells["技术资料"].Value;
                                                    dr["外形尺寸图"] = dgv1.Rows[i].Cells["外形尺寸图"].Value;
                                                    dr["实物照片图"] = dgv1.Rows[i].Cells["实物照片图"].Value;
                                                    dr["产品特点及用途"] = dgv1.Rows[i].Cells["产品特点及用途"].Value;
                                                    dr["备注"] = dgv1.Rows[i].Cells["备注"].Value;
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                    if (LevelIndex >= 0)
                                    {
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 12:
                    #region ERP软件编码
                    dt.Columns.Add("产品编码");
                    dt.Columns.Add("产品名称");
                    dt.Columns.Add("型号规格");
                    dt.Columns.Add("等级");
                    dt.Columns.Add("型号");
                    dt.Columns.Add("尺寸");
                    dt.Columns.Add("特性");
                    dt.Columns.Add("电压");
                    dt.Columns.Add("容量");
                    dt.Columns.Add("精度");
                    dt.Columns.Add("引出端形式");
                    dt.Columns.Add("执行标准");
                    dt.Columns.Add("产品大类");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) <= 0)
                                {

                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["产品编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["产品编码"]).Contains("--"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["产品编码"]).EndsWith("-"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Substring(0, GetString(dr["产品编码"]).Length - 1);
                                                        }
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["产品编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["产品编码"]).Contains("--"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["产品编码"]).EndsWith("-"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Substring(0, GetString(dr["产品编码"]).Length - 1);
                                                        }
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    dr["产品名称"] = dgv1.Rows[i].Cells["产品名称"].Value;
                                                    dr["等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["型号"] = dgv1.Rows[i].Cells["型号"].Value;
                                                    dr["尺寸"] = dgv1.Rows[i].Cells["尺寸"].Value;
                                                    dr["特性"] = strSpecials[k];
                                                    dr["电压"] = dgv1.Rows[i].Cells["电压"].Value;
                                                    dr["容量"] = strCurrentCapacity;
                                                    dr["精度"] = strAccuracies[j];
                                                    dr["引出端形式"] = strTerminals[m];
                                                    dr["执行标准"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["产品大类"] = dgv1.Rows[i].Cells["产品分类"].Value;
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["产品编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["产品编码"]).Contains("--"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["产品编码"]).EndsWith("-"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Substring(0, GetString(dr["产品编码"]).Length - 1);
                                                        }
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["产品编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["产品编码"]).Contains("--"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["产品编码"]).EndsWith("-"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Substring(0, GetString(dr["产品编码"]).Length - 1);
                                                        }
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    dr["产品名称"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "型多层瓷介电容器";
                                                    dr["等级"] = dgv1.Rows[i].Cells["质量等级"].Value;
                                                    dr["型号"] = dgv1.Rows[i].Cells["型号"].Value;
                                                    dr["尺寸"] = dgv1.Rows[i].Cells["尺寸"].Value;
                                                    dr["特性"] = strSpecials[k];
                                                    dr["电压"] = dgv1.Rows[i].Cells["电压"].Value;
                                                    dr["容量"] = strCurrentCapacity;
                                                    dr["精度"] = strAccuracies[j];
                                                    dr["引出端形式"] = strTerminals[m];
                                                    dr["执行标准"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["产品大类"] = dgv1.Rows[i].Cells["产品分类"].Value;
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                    if (LevelIndex >= 0)
                                    {
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 13:
                    #region 513所
                    dt.Columns.Add("产品编码");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("供货周期");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) <= 0)
                                {

                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["产品编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["产品编码"]).Contains("--"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["产品编码"]).EndsWith("-"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Substring(0, GetString(dr["产品编码"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["产品编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["产品编码"]).Contains("--"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["产品编码"]).EndsWith("-"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Substring(0, GetString(dr["产品编码"]).Length - 1);
                                                        }
                                                    }
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["等级描述"].Value;
                                                    dr["供货周期"] = dgv1.Rows[i].Cells["供货周期"].Value;
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["产品编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j];
                                                        while (GetString(dr["产品编码"]).Contains("--"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["产品编码"]).EndsWith("-"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Substring(0, GetString(dr["产品编码"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["产品编码"] = GetString(dgv1.Rows[i].Cells["质量等级"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["产品编码"]).Contains("--"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["产品编码"]).EndsWith("-"))
                                                        {
                                                            dr["产品编码"] = GetString(dr["产品编码"]).Substring(0, GetString(dr["产品编码"]).Length - 1);
                                                        }
                                                    }
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["等级描述"].Value;
                                                    dr["供货周期"] = dgv1.Rows[i].Cells["供货周期"].Value;
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                    if (LevelIndex >= 0)
                                    {
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
                case 14:
                    #region 五院
                    dt.Columns.Add("序号");
                    dt.Columns.Add("第1层分类名");
                    dt.Columns.Add("第2层分类名");
                    dt.Columns.Add("第3层分类名");
                    dt.Columns.Add("第4层分类名");
                    dt.Columns.Add("第5层分类名");
                    dt.Columns.Add("产品名称");
                    dt.Columns.Add("型号规格");
                    dt.Columns.Add("型号");
                    dt.Columns.Add("计量单位");
                    dt.Columns.Add("质量等级");
                    dt.Columns.Add("总规范");
                    dt.Columns.Add("详细规范");
                    dt.Columns.Add("封装形式");
                    dt.Columns.Add("外形尺寸");
                    dt.Columns.Add("专用条件");
                    dt.Columns.Add("附加协议");
                    dt.Columns.Add("电参数特选要求");
                    dt.Columns.Add("国产进口");
                    dt.Columns.Add("供应商名称");
                    for (int i = 0; i < dgv1.Rows.Count; i++)
                    {
                        try
                        {
                            string[] strSpecials = GetString(dgv1.Rows[i].Cells["特性"].Value).Split(new char[] { ';' });
                            for (int k = 0; k < strSpecials.Length; k++)
                            {
                                if (strSpecials[k].Trim().Equals(string.Empty))
                                {
                                    continue;
                                }
                                string strCapacityMin = GetString(dgv1.Rows[i].Cells["容量起"].Value);
                                string strCapacityMax = GetString(dgv1.Rows[i].Cells["容量止"].Value);
                                string strCurrentCapacity = strCapacityMin;
                                int LevelIndex = GetCapacityLevelIndex(strCurrentCapacity);
                                int PowerLevel = GetPowerLevel(strCurrentCapacity);
                                while (CompairTwoCapacity(strCurrentCapacity, strCapacityMax) <= 0)
                                {

                                    string[] strAccuracies = GetString(dgv1.Rows[i].Cells["精度"].Value).Split(new char[] { ';' });
                                    for (int j = 0; j < strAccuracies.Length; j++)
                                    {
                                        if (strAccuracies[j].Trim().Equals(string.Empty))
                                        {
                                            continue;
                                        }
                                        if (CompairTwoCapacity(strCurrentCapacity, "100") == -1)
                                        {
                                            if (strAccuracies[j] == "B" ||
                                                strAccuracies[j] == "C" ||
                                                strAccuracies[j] == "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity +"-"+
                                                            strAccuracies[j];
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity + "-" +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    dr["序号"] = GetString(dt.Rows.Count + 1);
                                                    dr["第1层分类名"]="元器件";
                                                    dr["第2层分类名"]="电容器";
                                                    dr["第3层分类名"]="固定电容器";
                                                    dr["第4层分类名"]="无机介质固定电容器";
                                                    dr["第5层分类名"]="瓷介电容器";
                                                    dr["产品名称"] = dgv1.Rows[i].Cells["产品名称"].Value;
                                                    dr["型号"] = dgv1.Rows[i].Cells["型号"].Value;
                                                    dr["计量单位"] = "只";
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["等级"].Value;
                                                    dr["总规范"] = "无";
                                                    dr["详细规范"] = "无";
                                                    dr["封装形式"] = dgv1.Rows[i].Cells["尺寸"].Value;
                                                    dr["外形尺寸"] = dgv1.Rows[i].Cells["外形尺寸"].Value;
                                                    dr["专用条件"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["附加协议"] = "无";
                                                    dr["电参数特选要求"] = "无";
                                                    dr["国产进口"] = "国产";
                                                    dr["供应商名称"] = "成都宏明电子科大新材料有限公司";
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (strAccuracies[j] != "B" &&
                                                strAccuracies[j] != "C" &&
                                                strAccuracies[j] != "D")
                                            {
                                                string[] strTerminals = GetString(dgv1.Rows[i].Cells["引出端形式"].Value).Split(new char[] { ';' });
                                                for (int m = 0; m < strTerminals.Length; m++)
                                                {
                                                    dr = dt.NewRow();
                                                    if (strTerminals[m].Trim().Equals(string.Empty))
                                                    {
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity + "-" +
                                                            strAccuracies[j];
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dr["型号规格"] = GetString(dgv1.Rows[i].Cells["型号"].Value) + "-" +
                                                            GetString(dgv1.Rows[i].Cells["尺寸"].Value) + "-" +
                                                            strSpecials[k] + "-" +
                                                            GetString(dgv1.Rows[i].Cells["电压"].Value) + "-" +
                                                            strCurrentCapacity + "-" +
                                                            strAccuracies[j] + "-" +
                                                            strTerminals[m];
                                                        while (GetString(dr["型号规格"]).Contains("--"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Replace("--", "-");
                                                        }
                                                        if (GetString(dr["型号规格"]).EndsWith("-"))
                                                        {
                                                            dr["型号规格"] = GetString(dr["型号规格"]).Substring(0, GetString(dr["型号规格"]).Length - 1);
                                                        }
                                                    }
                                                    dr["序号"] = GetString(dt.Rows.Count + 1);
                                                    dr["第1层分类名"] = "元器件";
                                                    dr["第2层分类名"] = "电容器";
                                                    dr["第3层分类名"] = "固定电容器";
                                                    dr["第4层分类名"] = "无机介质固定电容器";
                                                    dr["第5层分类名"] = "瓷介电容器";
                                                    dr["产品名称"] = dgv1.Rows[i].Cells["产品名称"].Value;
                                                    dr["型号"] = dgv1.Rows[i].Cells["型号"].Value;
                                                    dr["计量单位"] = "只";
                                                    dr["质量等级"] = dgv1.Rows[i].Cells["等级"].Value;
                                                    dr["总规范"] = "无";
                                                    dr["详细规范"] = "无";
                                                    dr["封装形式"] = dgv1.Rows[i].Cells["尺寸"].Value;
                                                    dr["外形尺寸"] = dgv1.Rows[i].Cells["外形尺寸"].Value;
                                                    dr["专用条件"] = dgv1.Rows[i].Cells["执行标准"].Value;
                                                    dr["附加协议"] = "无";
                                                    dr["电参数特选要求"] = "无";
                                                    dr["国产进口"] = "国产";
                                                    dr["供应商名称"] = "成都宏明电子科大新材料有限公司";
                                                    dt.Rows.Add(dr);
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    LevelIndex++;
                                    if (LevelIndex == StandardE24.Length)
                                    {
                                        LevelIndex = 0;
                                        PowerLevel++;
                                    }
                                    if (LevelIndex >= 0)
                                    {
                                        if (PowerLevel < 0)
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex].Substring(0, 1) + "R" + StandardE24[LevelIndex].Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCurrentCapacity = StandardE24[LevelIndex] + GetString(PowerLevel);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dgv1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            txtErrMsg.Text = "\n" + GetString(i + 1) + "行错误：" + ex.Message;
                            continue;
                        }
                    }
                    #endregion
                    break;
            }
            if (dt.Rows.Count > 0)
            {
                try
                {
                    if (dt.Rows.Count <= 65000)
                    {
                        WriteDataToFile(txtFileName_Target.Text, dt);
                    }
                    else
                    {
                        int iCount = 1;
                        int iRowsCount = 65000;
                        while (iRowsCount > 0)
                        {
                            DataTable ndt = dt.Clone();
                            DataRow tmpdr = ndt.NewRow();
                            for (int i = 0; i < dt.Columns.Count; i++)
                            {
                                tmpdr[i] = dt.Columns[i].ColumnName;
                            }
                            ndt.Rows.Add(tmpdr);
                            for (int i = 0; i < iRowsCount; i++)
                            {
                                ndt.ImportRow(dt.Rows[(iCount - 1) * 65000 + i]);
                            }
                            WriteDataToFile(txtFileName_Target.Text.Substring(0, txtFileName_Target.Text.Length - 4) + GetString(iCount) + ".xls", ndt);
                            iRowsCount = dt.Rows.Count - iCount * 65000;
                            if (iRowsCount > 65000)
                            {
                                iRowsCount = 65000;
                            }
                            iCount++;
                        }
                    }
                    MessageBox.Show("导出完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    txtErrMsg.Text = "\n导出为Excel错误：" + ex.Message;
                }
            }
        }

        

        private void ReadExcel()
        {
            if (cmbWorkSheetNames.SelectedIndex >= 0)
            {
                dgv1.DataSource = GetExcelDataTable(txtFileName_Source .Text , cmbWorkSheetNames .Text );
                if (dgv1.Rows.Count > 0)
                {
                    foreach (DataGridViewRow dgvr in dgv1.Rows)
                    {
                        dgvr.Cells["序号"].Value = dgvr.Index + 1;
                    }
                }
                dgv1.AutoResizeColumns();
            }
        }

        private DataTable GetExcelDataTable(string strEfn, string strEtn)
        {
            try
            {
                OleDbConnection _ExcelConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=\"Excel 8.0\";Data Source=" + strEfn);
                OleDbDataAdapter _ExcelOda = new OleDbDataAdapter("Select * from [" + strEtn + "]", _ExcelConn);
                DataTable _tmpDt = new DataTable();
                _ExcelConn.Open();
                _ExcelOda.Fill(_tmpDt);
                _ExcelConn.Close();
                return _tmpDt;
            }
            catch
            {
                return null;
            }
        }

        private void GetExcelTableNames(string strEFN)
        {
            cmbWorkSheetNames.Items.Clear();
            DataTable _dt = new DataTable();
            try
            {
                if (System.IO.File.Exists(strEFN))
                {
                    OleDbConnection _ExcelConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=\"Excel 8.0\";Data Source=" + strEFN);
                    _ExcelConn.Open();
                    _dt = _ExcelConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info, null);
                    _ExcelConn.Close();
                    DataView dv = _dt.DefaultView;
                    dv.RowFilter = "cardinality='0'";
                    _dt = dv.ToTable();
                }
            }
            catch
            {
            }
            if (_dt.Rows.Count > 0)
            {
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    cmbWorkSheetNames.Items.Add(_dt.Rows[i]["Table_Name"]);
                }
            }
        }

        private void WriteDataToFile(string strFileName,DataTable dt)
        {
            IWorkbook tmpBook = Factory.CreateWorkbook();
            tmpBook.Worksheets.Add();
            tmpBook.Worksheets[1].Range.SetDataTable(dt, false);
            tmpBook.SaveAs(strFileName);
        }

        private int GetCapacityLevelIndex(string strCapacity)
        {
            string strTmpCapacity = strCapacity;
            if (strTmpCapacity.ToLower().Contains("r"))
            {
                strTmpCapacity = strTmpCapacity.ToLower().Replace("r", "");
            }
            strTmpCapacity = strTmpCapacity.Substring(0, 2);
            for (int i = 0; i < StandardE24.Length; i++)
            {
                if (strTmpCapacity == StandardE24[i])
                {
                    return (i);
                }
                else 
                {
                    if (i==0)
                    {
                        if (Convert.ToDouble (strTmpCapacity) < Convert.ToDouble(StandardE24[i]))
                        {
                            return (-1);
                        }
                    }
                    else 
                    {
                        if (Convert.ToDouble(strTmpCapacity) > Convert.ToDouble(StandardE24[i-1])&& Convert.ToDouble(strTmpCapacity) < Convert.ToDouble(StandardE24[i]))
                        {
                            return (i-1);
                        }
                    }
                }
            }
            return (-1);
        }

        private int GetPowerLevel(string strCapacity)
        {
            string strTmpCapacity = strCapacity;
            int Result = 0;
            if (strTmpCapacity.ToLower().Contains("r"))
            {
                Result = -1;
            }
            else
            {
                int.TryParse(strTmpCapacity.Substring(2, 1), out Result);
            }
            return (Result);
        }

        private int CompairTwoCapacity(string Capacity1, string Capacity2)
        {
            float C1, C2;
            if (Capacity1.ToLower().Contains("r"))
            {
                float.TryParse(Capacity1.ToLower().Replace("r", "."), out C1);
            }
            else
            {
                C1 = (float)(int.Parse(Capacity1.Substring(0, 2)) * Math.Pow(10, int.Parse(Capacity1.Substring(2, 1))));
            }
            if (Capacity2.ToLower().Contains("r"))
            {
                float.TryParse(Capacity2.ToLower().Replace("r", "."), out C2);
            }
            else
            {
                C2 = (float)(int.Parse(Capacity2.Substring(0, 2)) * Math.Pow(10, int.Parse(Capacity2.Substring(2, 1))));
            }
            if (C1 > C2)
            {
                return (1);
            }
            if (C1 == C2)
            {
                return (0);
            }
            if (C1 < C2)
            {
                return (-1);
            }
            return (0);
        }

        private string CapactiyTranslate(string strC)
        {
            string strTmp = string.Empty;
            double dCapacity = 0d;
            //如果容量中包含PF字样，如195PF±0.5PF或16500PFJ
            if (strC.Contains("PF"))
            {
                strTmp = strC.Substring(0, strC.IndexOf('P'));
                dCapacity=GetDouble(strTmp);
            }
            //如果未包含PF字样，则一律按照三标法处理
            try
            {
                strTmp = strTmp.ToUpper();
                if (strTmp.Contains("R"))
                {
                    dCapacity = GetDouble(strTmp.Replace("R", "."));
                }
                else
                {
                    strTmp = strC.Substring(0, 3);
                    double iX = Convert.ToDouble(strTmp.Substring(0, 2));
                    double iY = Convert.ToDouble(strTmp.Substring(2, 1));
                    dCapacity = iX * Math.Pow(10, iY);
                }
            }
            catch
            {
                dCapacity = 0d;
            }
            string strCapcacity = dCapacity.ToString().Replace(".00", string.Empty)+"PF";
            return strCapcacity;
        }

        private string AccuraciesTranslate(string strAccuracies)
        {
            switch (strAccuracies )
            {
                case "B":
                    return "±0.1PF";
                    break;
                case "C":
                    return "±0.25PF";
                    break;
                case "D":
                    return "±0.5PF";
                    break;
                case "F":
                    return "±1%";
                    break;
                case "G":
                    return "±2%";
                    break;
                case "J":
                    return "±5%";
                    break;
                case "K":
                    return "±10%";
                    break;
                case "M":
                    return "±20%";
                    break;
                case "S":
                    return "+50%/-20%";
                    break;
                case "Z":
                    return "+80%/-20%";
                    break;
                case "P":
                    return "+100%/-20%";
                    break;
                default:
                    return string.Empty;
                    break;
            }
        }

        private string SpecialTranslate(string strSpecial)
        {
            switch (strSpecial)
            {
                case "200":
                    return "-56%～+22%";
                    break;
                case "2C0":
                    return "±20%";
                    break;
                case "2B1":
                    return "±10%";
                    break;
                case "2C1(不加偏压)":
                    return "±20%";
                    break;
                case "2C1(加偏压)":
                    return "-30%～+20%";
                    break;
                case "2C1":
                    return "±20%";
                    break;
                case "2C2":
                    return "±20%";
                    break;
                case "2E2":
                    return "-56%～+22%";
                    break;
                case "2E3":
                    return "-56%～+22%";
                    break;
                case "2F2":
                    return "-80%～+30%";
                    break;
                case "2F4":
                    return "-80%～+30%";
                    break;
                case "2X1":
                    return "±15%";
                    break;
                case "2R1":
                    return "±15%";
                    break;
                case "A":
                    return "100±30ppm/℃";
                    break;
                case "B":
                    return "-65%～+20%";
                    break;
                case "BA":
                    return "100±30ppm/℃";
                    break;
                case "BC":
                    return "0±30ppm/℃";
                    break;
                case "BP":
                    return "0±30ppm/℃";
                    break;
                case "BU":
                    return "-82%～+22%";
                    break;
                case "BV":
                    return "-82%～+22%";
                    break;
                case "BX":
                    return "±15%";
                    break;
                case "BY":
                    return "±15%(不加偏压)";
                    break;
                case "CD":
                    return "-20±15ppm/℃";
                    break;
                case "CF":
                    return "0±15ppm/℃";
                    break;
                case "CG":
                    return "0±30ppm/℃";
                    break;
                case "CH":
                    return "0±60ppm/℃";
                    break;
                case "COG":
                    return "0±30ppm/℃";
                    break;
                case "COH":
                    return "0±60ppm/℃";
                    break;
                case "D":
                    return "-3300±1000ppm/℃";
                    break;
                case "E":
                    return "-4700±1000ppm/℃";
                    break;
                case "K":
                    return "-2200±500ppm/℃";
                    break;
                case "M":
                    return "±15%";
                    break;
                case "M7G":
                    return "100±30ppm/℃";
                    break;
                case "NP":
                    return "-750±200ppm/℃";
                    break;
                case "NR":
                    return "-1500±500ppm/℃";
                    break;
                case "NS":
                    return "-2400±500ppm/℃";
                    break;
                case "NU":
                    return "-3700±1000ppm/℃";
                    break;
                case "NV":
                    return "-4700±1000ppm/℃";
                    break;
                case "NPO":
                    return "0±30ppm/℃";
                    break;
                case "SL":
                    return string.Empty;
                    break;
                case "U":
                    return "-750±250ppm/℃";
                    break;
                case "UX":
                    return "±15%";
                    break;
                case "V":
                    return "-1500±500ppm/℃";
                    break;
                case "X5R":
                    return "±15%";
                    break;
                case "X7Q":
                    return "-30%～+60%";
                    break;
                case "X7R":
                    return "±15%";
                    break;
                case "X8R":
                    return "±20%";
                    break;
                case "X8S":
                    return "-45%～+20%";
                    break;
                case "X9U":
                    return "-65%～+20%";
                    break;
                case "Y5U":
                    return "-56%～+22%";
                    break;
                case "Y5V":
                    return "-82%～+22%";
                    break;
                case "Y7S":
                    return "±22%";
                    break;
                default:
                    return string.Empty;
            }
        }

        private string GetString(object tmpobj)
        {
            try
            {
                return tmpobj.ToString().Trim ();
            }
            catch
            {
                return string.Empty;
            }
        }

        private double GetDouble(object tmpobj)
        {
            try
            {
                return Convert.ToDouble(tmpobj);
            }
            catch
            {
                return 0d;
            }
        }

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 0)
            {
                dgv1.AutoResizeColumns();
            }
        }

        private void cmbWorkSheetNames_SelectedIndexChanged(object sender, EventArgs e)
        {
            ReadExcel();
        }

        private void cmbType_SelectedIndexChanged(object sender, EventArgs e)
        {
            dgv1 .DataSource =null ;
            dgv1.Columns.Clear();
            switch (cmbType.SelectedIndex)
            {
                case 0:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 1:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("滤波电路形式", "滤波电路形式");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量", "容量");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("配套电连接器标准代号", "配套电连接器标准代号");
                    dgv1.Columns.Add("配套电连接器绝缘安装板代号", "配套电连接器绝缘安装板代号");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 2:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("阻值", "阻值");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("电极材料代码", "电极材料代码");
                    dgv1.Columns.Add("引出端形式", "引出端形式");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 3:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 4:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 5:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量", "容量");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 6:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("电极外形代码", "电极外形代码");
                    dgv1.Columns.Add("电极材料代码", "电极材料代码");
                    dgv1.Columns.Add("电容数量", "电容数量");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 7:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("堆叠与封装类型", "堆叠与封装类型");
                    dgv1.Columns.Add("尺寸代号、堆叠只数", "尺寸代号、堆叠只数");
                    dgv1.Columns.Add("引出端形式", "引出端形式");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 8:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("元器件名称", "元器件名称");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("引出端形式", "引出端形式");
                    dgv1.Columns.Add("工作温度范围", "工作温度范围");
                    dgv1.Columns.Add("封装形式", "封装形式");
                    dgv1.Columns.Add("封装尺寸", "封装尺寸");
                    dgv1.Columns.Add("规范号", "规范号");
                    dgv1.Columns.Add("认证源", "认证源");
                    dgv1.Columns.Add("替代型号", "替代型号");
                    dgv1.Columns.Add("介质类型", "介质类型");
                    dgv1.Columns.Add("电子手册", "电子手册");
                    break;
                case 9:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("分类", "分类");
                    break;
                case 10:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("产品名称", "产品名称");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("客户等级", "客户等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("引出端形式", "引出端形式");
                    dgv1.Columns.Add("外形尺寸", "外形尺寸");
                    break;
                case 11:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("COMPID", "COMPID");
                    dgv1.Columns.Add("发布情况", "发布情况");
                    dgv1.Columns.Add("是否同意在2016年版发布", "是否同意在2016年版发布");
                    dgv1.Columns.Add("不发布的理由", "不发布的理由");
                    dgv1.Columns.Add("生产商", "生产商");
                    dgv1.Columns.Add("元器件名称", "元器件名称");
                    dgv1.Columns.Add("系列型号", "系列型号");
                    dgv1.Columns.Add("详细规格", "详细规格");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("引出端形式", "引出端形式");
                    dgv1.Columns.Add("供货状态", "供货状态");
                    dgv1.Columns.Add("通用规范编号", "通用规范编号");
                    dgv1.Columns.Add("详细规范编号", "详细规范编号");
                    dgv1.Columns.Add("附加技术协议", "附加技术协议");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("封装外形", "封装外形");
                    dgv1.Columns.Add("替代型号(厂家)", "替代型号(厂家)");
                    dgv1.Columns.Add("是否使用进口芯片", "是否使用进口芯片");
                    dgv1.Columns.Add("项目来源", "项目来源");
                    dgv1.Columns.Add("单价", "单价");
                    dgv1.Columns.Add("年供货能力", "年供货能力");
                    dgv1.Columns.Add("生产供货周期", "生产供货周期");
                    dgv1.Columns.Add("重量", "重量");
                    dgv1.Columns.Add("耐久性试验", "耐久性试验");
                    dgv1.Columns.Add("鉴定类型", "鉴定类型");
                    dgv1.Columns.Add("鉴定日期", "鉴定日期");
                    dgv1.Columns.Add("组织鉴定机构", "组织鉴定机构");
                    dgv1.Columns.Add("详细规范", "详细规范");
                    dgv1.Columns.Add("技术资料", "技术资料");
                    dgv1.Columns.Add("外形尺寸图", "外形尺寸图");
                    dgv1.Columns.Add("实物照片图", "实物照片图");
                    dgv1.Columns.Add("产品特点及用途", "产品特点及用途");
                    dgv1.Columns.Add("备注", "备注");
                    break;
                case 12:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("产品名称", "产品名称");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("引出端形式", "引出端形式");
                    dgv1.Columns.Add("产品分类", "产品分类");
                    break;
                case 13:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("质量等级", "质量等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("引出端形式", "引出端形式");
                    dgv1.Columns.Add("等级描述", "等级描述");
                    dgv1.Columns.Add("供货周期", "供货周期");
                    break;
                case 14:
                    dgv1.Columns.Add("序号", "序号");
                    dgv1.Columns.Add("产品名称", "产品名称");
                    dgv1.Columns.Add("等级", "等级");
                    dgv1.Columns.Add("型号", "型号");
                    dgv1.Columns.Add("尺寸", "尺寸");
                    dgv1.Columns.Add("特性", "特性");
                    dgv1.Columns.Add("电压", "电压");
                    dgv1.Columns.Add("容量起", "容量起");
                    dgv1.Columns.Add("容量止", "容量止");
                    dgv1.Columns.Add("精度", "精度");
                    dgv1.Columns.Add("引出端形式", "引出端形式");
                    dgv1.Columns.Add("总规范", "总规范");
                    dgv1.Columns.Add("详细规范", "详细规范");
                    dgv1.Columns.Add("外形尺寸", "外形尺寸");
                    dgv1.Columns.Add("执行标准", "执行标准");
                    break;
            }
            for (int i = 0; i < dgv1.Columns.Count; i++)
            {
                dgv1.Columns[i].DataPropertyName = dgv1.Columns[i].Name;
            }
            if (!txtFileName_Source.Text.Equals(string.Empty))
            {
                ReadExcel();
            }
        }

    }
}